<?php
global $_GPC, $_W;
$GLOBALS['frames'] = $this->getNaveMenu();
                $user=pdo_get('users',array('username'=>$_W['username']));
                $uniacid=pdo_get('users_permission',array('uid'=>$user['uid']));
// $cates = pdo_fetchall("SELECT * FROM " . tablename('zh_yjm_assistanttype'));
// $cur = pdo_get('zh_yjm_assistant',array('id'=>$_GPC['id']));
// $c_id=$cur['assistanttype_id'];
// function gethtmlTree($data, $pId,$num=0,$c_id)
// {
// $html = '';
// $num++;
//   foreach($data as $k => $v)
//   {
//      if($v['p_id'] == $pId)
//      {
//       $html .= '<option value="'.$v['id'].'"'.(($v['id']== $c_id) ? 'selected="selected"' : '') . '>'.str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;',$num-1)."|-".$v['title'];
//       $html .= gethtmlTree($data, $v['id'],$num,$c_id);
//       $html = $html."</option>";
//      }
//   }
// return $html;
// }
// $cates=gethtmlTree($cates, 0,$num,$c_id);

// $item = pdo_get('zh_yjm_assistant',array('id'=>$_GPC['id']));

// $assistanttype = pdo_fetchall("SELECT * FROM " . tablename('zh_yjm_assistanttype'));
$item = pdo_get('zh_yjm_assistant',array('id'=>$_GPC['id']));
$admin = pdo_get('zh_yjm_store',array('admin'=>$user['username']));
if(checksubmit('submit')){
        $data['sort']=$_GPC['sort'];
        // $data['title']=$_GPC['title'];
        $data['number']=$_GPC['number'];
        // $data['img']=$_GPC['img'];
        $data['store_id']=$admin['id'];
        $data['assistant']=$_GPC['assistant'];
        $data['name']=$_GPC['name'];
        // $data['phone']=$_GPC['phone'];
        // $data['area']=$_GPC['area'];
        // $data['latlng']=$_GPC['latlng'];
        // $data['admin']=$_GPC['admin'];
        // $data['password']=$_GPC['password'];
        // $data['imgs']=implode(",",$_GPC['imgs']);
        // $data['detail']=html_entity_decode($_GPC['detail']);
        $data['time']=date('Y-m-d H:i:s',time());
        $data['uniacid']=$uniacid['uniacid'];
        if($_GPC['id']==''){  
            $rst=pdo_insert('zh_yjm_assistant',$data);      
            if($rst){
                 message('添加成功！', $this->createWebUrl2('assistant'), 'success');
            }else{
                 message('添加失败！','','error');
            }
        }else{
             $rst=pdo_update('zh_yjm_assistant',$data,array('id'=>$_GPC['id']));
            if($rst){
                 message('编辑成功！', $this->createWebUrl2('assistant'), 'success');
            }else{
                 message('编辑失败！','','error');
            }
        }
}
include $this->template('web/addassistant');